<?php
use yii\helpers\Url;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use kartik\date\DatePicker;
use kartik\file\FileInput;
use yii\bootstrap\Modal;

/* @var $this yii\web\View */
/* @var $model app\models\Users */
/* @var $form yii\widgets\ActiveForm */
$data = \app\models\School::find()->all();
$js = <<<JS
//监听手机号change 事件

 $("#users-mobile").change(function(){
   var mobile = $(this).val();
   if (mobile.length < 11) return;
   var password =  mobile.substr(5);
   $("#users-gl_passwors").val(password);
  });
JS;
$this->registerJs($js);
?>

<div class="users-form">
    <?php
    if ($model->hasErrors()) {
        \yii\bootstrap\Alert::begin(
            [
                'options' => [
                    'class' => 'alert-warning',
                ]
            ]
        );
        echo Html::errorSummary($model);
        \yii\bootstrap\Alert::end();
    }
    ?>

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'gl_username')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'mobile')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>


    <?= $form->field($model, 'gl_passwors')->textInput(['maxlength' => true]) ?>

    <?php echo $form->field($model, 'touxiang')->widget(FileInput::classname(), [
        'options' => ['accept' => 'image/*'],
    ]);?>

    <?= $form->field($model, 'entry_time')->widget(DatePicker::classname(), [
        'options' => ['placeholder' => ''],
        'pluginOptions' => [
            'autoclose' => true,
            'todayHighlight' => true,
            'format' => 'yyyy-mm-dd',
        ]
    ]); ?>

    <?= $form->field($model, 'off_time')->widget(DatePicker::classname(), [
        'options' => ['placeholder' => '请点击选择日期'],
        'pluginOptions' => [
            'autoclose' => true,
            'todayHighlight' => true,
            'format' => 'yyyy-mm-dd',
        ]
    ]); ?>

    <?= $form->field($model, 'quanxian')->radioList(['1'=>'园长','2'=>'幼儿园管理员','3'=>'主班老师','4'=>'副班老师','5'=>'生活老师']) ?>

    <?= $form->field($model, 'guard_status')->radioList(['1'=>'在岗','0'=>'离岗']) ?>

    <?=  $form->field($model, 'yey_id')->dropDownList(ArrayHelper::map($data,'yey_id', 'yey_mingcheng')); ?>

    <?=  $form->field($model, 'bj_id')->dropDownList(ArrayHelper::map(\app\models\Classname::find()->all(),'class_id', 'class_name')); ?>



    <?php if (!Yii::$app->request->isAjax){ ?>
	  	<div class="form-group">
	        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
	    </div>
	<?php } ?>

    <?php ActiveForm::end(); ?>
    
</div>
